#ifndef UDPWORKER_H
#define UDPWORKER_H

#include <QObject>
#include <QUdpSocket>
#include <QHostAddress>
#include <QTimer>

class UdpWorker : public QObject
{
Q_OBJECT
public:
    explicit UdpWorker(const char *inface, QObject *parent = nullptr);

    ~UdpWorker() override;

    int dataSend(const QByteArray &datagram);

    int dataSend(const char *datagram, int n);

    bool waitForRecvBytes(int msec);

signals:

    void dataRecvdBytes(QByteArray &datagram);

public slots:

//    void dataRecv(QByteArray& datagram);
    void dataRecv();

private:
    QUdpSocket mUdpTxSocket;
    QUdpSocket mUdpRxSocket;
    QByteArray mRxDatagram;
};

#endif // UDPWORKER_H
